package com.jin.lazytool.handler;

import java.time.LocalDateTime;

public class CountLoopHandler extends ILoopHandler{
    public CountLoopHandler(){}

    private Integer count;
    private Integer jumpCount;
    private CountLoopHandler(Integer count,Integer jumpCount){
        this.count = count;
        this.jumpCount = jumpCount;
    }

    @Override
    public Integer execute(Integer index) throws InterruptedException {
        if(count <= 0){
            return index + jumpCount;
        }
        count --;
        Thread.sleep(time);
        return index;
    }

    @Override
    public ILoopHandler newHandler(Integer count, long timer, LocalDateTime dateTime, String js,Integer jumpCount) {
        return new CountLoopHandler(count,jumpCount);
    }
}
